<template>
  <el-select :value="postId" :disabled="disabled" @change="changePost">
    <el-option
      v-for="item in dataList"
      :key="item.id"
      :label="item.postName"
      :value="item.id"
    >
    </el-option>
  </el-select>
</template>

<script>
import postApi from '@/api/system/postApi'

export default {
  name: 'Post',
  props: {
    disabled: {
      type: Boolean,
      default: false
    },
    value: {
      type: Number,
      default: null
    }
  },
  data() {
    return {
      dataList: []
    }
  },
  computed: {
    postId() {
      return this.value
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      postApi.getList({}).then(res => {
        this.dataList = res.data
      })
    },
    changePost(value) {
      console.log(value)
      this.$emit('input', value)
    }
  }
}
</script>

<style scoped>

</style>
